package hpasDAO;

import hpasDataEntities.DetailedType;
import hpasDataEntities.GeneralType;

import javax.swing.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;

public class GeneralTypeDAO
{
    private Connection conn;
    /** 创建数据库访问接口 **/
    public GeneralTypeDAO()
    {
        try
        {
            connect();
        }
        catch (SQLException e)
        {
            JOptionPane.showMessageDialog(null,"数据库建立连接失败",
                    "错误",JOptionPane.ERROR_MESSAGE);
        }
        catch (ClassNotFoundException e)
        {
            JOptionPane.showMessageDialog(null,"找不到MySQL驱动程序",
                    "错误",JOptionPane.ERROR_MESSAGE);
        }
    }
    /** 创建连接 **/
    private void connect() throws SQLException, ClassNotFoundException
    {
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hpas","root", "niuniu53");
    }
    /** 添加新大类 **/
    public void addGeneralType(GeneralType generalType) throws SQLException
    {}

    /** 删除大类 **/
    public void removeGeneralType(GeneralType generalType) throws SQLException
    {}

    /** 查询大类 **/
    public GeneralType getGeneralType(int id) throws SQLException
    {
        return null;
    }

    /** 修改大类 **/
    public void updateGeneralTyoe(GeneralType newGen) throws SQLException
    {}

    /** 查询大类下子类 **/
    public ArrayList<DetailedType> getAffiliatedDetailedType(GeneralType generalType)
        throws SQLException
    {
        return null;
    }
}
